package com.wgy.designmode.action.mediator.mediator;

import com.wgy.designmode.action.mediator.colleague.Colleague;

import java.util.ArrayList;
import java.util.List;

public class ChatRoom implements Mediator{

    private List<Colleague> colleagues = new ArrayList<>();
    @Override
    public void sendMessage(String message, Colleague colleague) {
        for (Colleague col : colleagues) {
            if (col != colleague){
                col.receive(message);
            }
        }
    }

    @Override
    public void addColleague(Colleague colleague) {
        colleagues.add(colleague);
    }
}
